#!/bin/bash

echo 'Interfaces FTP Server'

echo 'eth0  red I'
ifconfig eth0 10.31.25.1 netmask 255.255.255.128
 
echo 'Asignando rutas'
#RED A
route add -net 10.26.29.32 netmask 255.255.255.240 gateway 10.31.25.2 metric 1
#route add -net 10.26.29.32 netmask 255.255.255.240 gateway 10.31.25.130 metric 10

#RED B
route add -net 10.31.25.192 netmask 255.255.255.224 gateway 10.31.25.2 metric 1
#route add -net 10.31.25.192 netmask 255.255.255.224 gateway 10.31.25.130 metric 10

#RED C
route add -net 192.168.56.0 netmask 255.255.255.0 gateway 10.31.25.2 metric 1 
#route add -net 192.168.56.0 netmask 255.255.255.0 gateway 10.31.25.130 metric 10

#RED D
route add -net 10.64.73.0 netmask 255.255.255.0 gateway 10.31.25.2 metric 1
#route add -net 10.64.73.0 netmask 255.255.255.0 gateway 10.31.25.130 metric 10

#RED E
route add -net 132.86.10.0 netmask 255.255.255.252 gateway 10.31.25.2 metric 1
#route add -net 132.86.10.0 netmask 255.255.255.252 gateway 10.31.25.130 metric 10

#RED F
route add -net 10.26.29.56 netmask 255.255.255.252 gateway 10.31.25.2 metric 1
#route add -net 10.26.29.56 netmask 255.255.255.252 gateway 10.31.25.130 metric 10

#RED G
route add -net 10.26.29.128 netmask 255.255.255.128 gateway 10.31.25.2 metric 1
#route add -net 10.26.29.128 netmask 255.255.255.252 gateway 10.31.25.130 metric 10

#RED H
route add -net 10.26.29.60 netmask 255.255.255.252 gateway 10.31.25.2 metric 1
#route add -net 10.26.29.60 netmask 255.255.255.252 gateway 10.31.25.130 metric 10

#RED I
echo 'Red L directamente conectada'

#RED J
route add -net 10.31.25.128 netmask 255.255.255.128 gateway  10.31.25.226 metric 1

#RED K
route add -net 172.51.5.192 netmask 255.255.255.252 gateway 10.31.25.2 metric 1
#route add -net 172.51.5.192 netmask 255.255.255.252 gateway 10.31.25.130 metric 10

#RED L
route add -net 10.31.25.128 netmask 255.255.255.128 gateway  10.31.25.226 metric 1

#RED M
route add -net 10.26.29.0 netmask 255.255.255.224 gateway 10.31.25.2 metric 1
#route add -net 10.26.29.0 netmask 255.255.255.224 gateway 10.31.25.130 metric 10

#RED N
route add -net 10.26.29.48 netmask 255.255.255.248 gateway 10.31.25.2 metric 1
#route add -net 10.26.29.48 netmask 255.255.255.248 gateway 10.31.25.225 metric 10

#RED O
route add -net 10.86.5.0 netmask 255.255.255.0 gateway 10.31.25.2 metric 1
#route add -net 10.86.5.0 netmask 255.255.255.0 gateway 10.31.25.130 metric 10

#RED P
route add -net 132.86.10.4 netmask 255.255.255.252 gateway 10.31.25.2 metric 1
#route add -net 132.86.10.4 netmask 255.255.255.252 gateway 10.31.25.130 metric 10

#RED Q
route add -net 172.51.5.196 netmask 255.255.255.252 gateway  10.31.25.2 metric 1
#route add -net 172.51.5.196 netmask 255.255.255.252 gateway 10.31.25.130 metric 10

#RED R
route add -net 172.51.5.200 netmask 255.255.255.252 gateway  10.31.25.2 metric 1
#route add -net 172.51.5.200 netmask 255.255.255.252 gateway  10.31.25.130 metric 10


echo 'Configurando Servicio FTP'
echo ""
echo "verificado si esta disponible el servicio vsftpd..."

if [ ! -e /etc/init.d/vsftpd ]
then
  echo "el servicio parece no encontrarse instalado, se intenta instalar"
  apt-get -y install vsftpd
fi

if [ ! -e /etc/init.d/vsftpd ]
then
  echo "el servicio de FTP no ha podido ser instalado. por favor verifique el inconveniente "
  exit 1
else
  echo "el servicio está instalado correctamente, se inicia la configuracion"
fi

#cp ./inetd.conf /etc/inetd.conf
cp ./vsftpd.conf /etc/vsftpd.conf
/etc/init.d/vsftpd stop
/etc/init.d/vsftpd start

echo "Listo el pollo"


